package com.thd.springboottest.springbootextends.custombeanfactorypostprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

import java.util.stream.Stream;

/**
 * com.thd.springboottest.springbootextends.custombeanfactorypostprocessor.MyBeanFactoryPostProcessor
 *
 * @author: wanglei62
 * @DATE: 2022/4/22 14:47
 **/
@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        String[] iocBeanNames = configurableListableBeanFactory.getBeanDefinitionNames();

        System.out.println("======================= 扩展  可以在 MyBeanFactoryPostProcessor 这里修改beanDefinition的元数据 =======================");
        System.out.println(" 以下是所有注册到IOC容器中的beanDefinition");
        System.out.println(" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ");
        Stream.of(iocBeanNames).forEach(System.out::println);
        System.out.println(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ");
    }
}
